// 存储token
const TOKEN_KEY = 'leju-admin-token'
const USER_INFO_KEY = 'leju-admin-userInfo'
export function setToken(token) {
  window.localStorage.setItem(TOKEN_KEY, token)
}
export function getToken() {
  return window.localStorage.getItem(TOKEN_KEY)
}

export function removeToken() {
  window.localStorage.removeItem(TOKEN_KEY)
}

export function setUserInfo(userInfo) {
  var userInfos = JSON.stringify(userInfo)
  window.localStorage.setItem(USER_INFO_KEY, userInfos)
}
export function getUserInfo() {
  var userInfoStr = window.localStorage.getItem(USER_INFO_KEY)
  if (userInfoStr) {
    return JSON.parse(userInfoStr)
  }
  return null
}
export function removeUserInfo() {
  window.localStorage.removeItem(USER_INFO_KEY)
}

export function clearUserCache() {
  removeUserInfo()
  removeToken()
}
